import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import sun.nio.cs.StandardCharsets;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class AddCol {
    public static void main(String[] args) throws IOException{
        readColumn();
    }
    //
    public static void readColumn() throws IOException {
        String src="G:\\毕业论文\\数据集\\addTask.csv";
        BufferedReader bufferedReader=new BufferedReader(new FileReader(src));
        String line=null;
        //line=bufferedReader.readLine();
        BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter("G:\\毕业论文\\数据集\\4.csv"));
        Random random=new Random();
        int i = random.nextInt(12);
        List<String> list=new ArrayList<String>();
        list.add("");
        while ((line=bufferedReader.readLine())!=null){
            //如果读取的行不为空，将其按照逗号隔开
            String[] split = line.split(",");
            //获取第五列的数据
            String last=split[4];
            String s = list.get(list.size() - 1);
            if (s.equals(last)){
                //如果后一行的数等于前一行的数，就加上与上次相同的数
            }
            else {
                //若两个数不相等，那么加入一个新的随机数
                Random random2=new Random();
                int tempi = random2.nextInt(12);
                int tempj = random2.nextInt(12);
                if (tempi>tempj)
                i=random2.nextInt(tempi-tempj+1)+tempj;
                else if (tempj>tempi)
                    i=random2.nextInt(tempj-tempi+1)+tempi;
                else
                    i=tempi;

                //bufferedWriter.newLine();
            }
            bufferedWriter.write(String.valueOf(i)+"\r\n");
            list.add(last);
            System.out.println(last);
        }
        bufferedReader.close();
        bufferedWriter.flush();
        bufferedWriter.close();

    }
}
